Skip to content

Security & IPC hardening: sender-derived origins, APPROVE_SIGNING guard, UUID correlation IDs, and toolbar badge - #42

Merged
jjohare merged 1 commit into
mainfrom
security/ipc-origin-hardening
Nov 28, 2026
Merged

jjohare merged 1 commit into
mainfrom
security/ipc-origin-hardening

Conversation

@jjohare

@jjohare jjohare commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

Hardens background message handling and IPC hygiene (intentionally leaving NIP-98 untouched so it does not conflict with the isolated fix/nip98-caller work), and adds a toolbar lock/unlock badge indicator.

Changes

  • Authoritative sender-derived origin across all NIP-07 / NIP-44 handlers (src/background.js):
    • Uses pageOrigin(sender, origin) consistently for GET_PUBLIC_KEY, SIGN_EVENT, NIP44_ENCRYPT, and NIP44_DECRYPT (matching SIDESTR_SIGN_TRANSACTION), ignoring spoofed message.origin values when Chrome provides sender.origin / sender.url, and rejecting empty origins.
  • Extension-UI-only guard on APPROVE_SIGNING (src/background.js):
    • Rejects APPROVE_SIGNING messages unless isExtensionUiSender(sender) is true, preventing content scripts from attempting to self-approve requests.
  • Remove unused NIP44_GET_CONVERSATION_KEY handler (src/background.js):
    • Removes dead key-derivation surface area that is not exposed by nostr-provider.js or injected.js.
  • Collision-resistant IPC correlation IDs (src/nostr-provider.js):
    • Uses crypto.randomUUID() (with fallback) instead of Math.random().toString(36).substring(7).
  • Toolbar lock/unlock badge & tooltip (src/background.js):
    • Displays a LOCK badge and descriptive tooltip (Podkey — Locked (click to unlock) / Podkey — Unlocked / Podkey — Set up your key) synced across startup, vault operations, and storage changes.

Testing

  • npm run build
  • npm test (246/246 passing, including new tests for spoofed-origin protection, APPROVE_SIGNING sender enforcement, removed NIP44_GET_CONVERSATION_KEY, and toolbar badge state)
  • npm run lint

@jjohare
jjohare merged commit 7dcf394 into main Nov 28, 2026
2 checks passed
@jjohare
jjohare deleted the security/ipc-origin-hardening branch November 28, 2026 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant